#include<vector>
using namespace std;

class Solution {
public:
    int numberOfArithmeticSlices(vector<int>& A) {
        int* dp = new int[A.size()];
        memset(dp, 0, sizeof(int) * A.size());
        int res = 0;
        for (int i = 2; i < A.size(); ++i) {
            if (A[i] - A[i - 1] == A[i - 1] - A[i - 2])
                dp[i] = 1 + dp[i - 1];
            res += dp[i];
        }
        return res;

    }
};